package com.websuites.web.servlet.transport;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;

import com.websuites.web.servlet.response.WsHttpServletResponseWrapper;
import com.websuites.web.servlet.transport.bex.IBexConnection;

@SuppressWarnings("unchecked")
public class TransportServletResponse extends WsHttpServletResponseWrapper
{
	private IBexConnection conn;
	
	public TransportServletResponse(IBexConnection conn)
	{
		super(conn.getResponse()); 
		this.conn = conn;
	} 
	
	public PrintWriter getWriter() throws IOException 
	{
		synchronized(this)
		{
			if(writer == null)
			{
				writer = new TransportWriter(conn);
			}
		}
		return writer;
	}
	
	public void send(Object data)
	{
		conn.sendData(data);
	}
	
	public void send(HashMap bexContext,Object data)
	{
		conn.sendData(data, bexContext);
	}
	public ITransportConnection getTranpsortConnection()
	{
		return conn;
	}

	private PrintWriter writer;
}
